<template>
  <a-modal :open="open" width="840px" title="修改备注" centered :keyboard="false" @ok="onOk" @cancel="onCancel">
    <div>
      <div class="w-full h-18 patient-info-header py-2 px-3 flex items-center mb-4 justify-between">
        <div class="flex items-center">
          <a-avatar :size="48" :src="avatarMan" />
          <div class="text-xl font-semibold max-w-28 min-w-20 truncate text-white ml-4">
            {{ formState?.brName || '姓名' }}
          </div>
          <div class="text-white">
            <span class="ml-4 mr-4">{{ formState?.brXb || '性别' }}</span>
            <span class="ml-4">{{ formState?.brAge ? formState?.brAge : '年龄' }}</span>
          </div>
          <div class="text-white ml-6 mr-38">{{ formState?.phone || '-' }}</div>
        </div>
        <div class="flex w-[400px]">
          <div class="flex-1">
            <div class="text-center text-white">{{ formState?.id || '-' }}</div>
            <div class="text-xs text-center font-bold text-[#aaaaaa]">销售单号</div>
          </div>
          <div class="flex-1">
            <div class="text-center text-white">{{ formState?.handlerName || '-' }}</div>
            <div class="text-xs text-center font-bold text-[#aaaaaa]">经手人</div>
          </div>
          <div class="flex-1">
            <div class="text-center text-white">{{ formState?.chkEmpName || '-' }}</div>
            <div class="text-xs text-center font-bold text-[#aaaaaa]">验光医生</div>
          </div>
          <div class="flex-1">
            <div class="text-center text-white">{{ formState?.doctorName || '-' }}</div>
            <div class="text-xs text-center font-bold text-[#aaaaaa]">配镜医生</div>
          </div>
        </div>
      </div>
    </div>

    <a-form :model="formState" :colon="false">
      <a-form-item label="备注" class="w-full mt-2">
        <a-textarea v-model:value="formState.memo" :rows="6" placeholder="请输入" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script setup>
import { ref, watch } from 'vue'
import { message } from 'ant-design-vue'
import { post } from '@/utils/request'
import avatarMan from '@/assets/images/avatar-man.png'

const props = defineProps({
  open: Boolean,
  rowData: {
    type: Object,
    default: () => ({})
  }
})

const emit = defineEmits(['update:open', 'success'])
const formState = ref({
  memo: ''
})

const onOk = async () => {
  const res = await post('/optometry/ooadolescentcheck/doSaveOoOpticianRecordMemo', { ooOpticianRecordId: formState.value.id, memo: formState.value.memo })
  res.code !== 0 ? message.error(res.msg || '操作失败') : message.success('保存成功')
  onCancel()
  emit('success')
}
const onCancel = () => {
  emit('update:open', false)
}
watch(
  () => props.open,
  () => {
    formState.value = { ...props.rowData }
  }
)
</script>
<style lang="less" scoped>
.ant-form {
  display: flex;
  flex-flow: row wrap;
  min-width: 0;
  :deep(.ant-form-item) {
    .ant-form-item-label {
      width: 100px;
    }
  }
  .ant-picker {
    width: 100%;
  }
}
.right-border-pro {
  border: 1px solid var(--primary-color);
  border-radius: 4px;
}
.patient-info-header {
  background-color: var(--primary-color);
  border-radius: 3px;
}
</style>
